home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d2 / uneedit.arc / SYSID32.ARC / CPUID.ASM next >
Assembly Source File  |  1988-12-17  |  2KB  |  112 lines

  1. ;-----------------------------------------------------------------------------
  2. ;
  3. ;    CPUID.ASM
  4. ;    Version 1.1
  5. ;
  6. ;    A procedure used by SYSID.PAS.
  7. ;
  8. ;    CPUID returns these values in AX:
  9. ;        AH7 :    (not used, always 0)
  10. ;        AH6 :    (not used, always 0)
  11. ;        AH5 :    (not used, always 0)
  12. ;        AH4 :    (not used, always 0)
  13. ;        AH3 :    1 if CPU mishandles interrupts of multi-prefix string
  14. ;            instructions (Intel)
  15. ;        AH2 :    1 if PUSH SP writes, then decrements (80286)
  16. ;        AH1 :    1 if shift instructions ignore high 3 bits in register
  17. ;            displacement (8018x, 80286)
  18. ;        AH0 :    1 if prefetch instruction queue is 6 bytes (80x86)
  19. ;        AL :     0 if no coprocessor present
  20. ;            1 if 8087 present
  21. ;            2 if 80287 present
  22. ;
  23. ;    CPUID uses self-modifying code to determine the length of the prefetch
  24. ;    instruction queue and should therefore be run only once in the course
  25. ;    of the calling program.
  26. ;
  27. ;    CPUID was shamelessly stolen from Bob Smith's article "Chips in
  28. ;    Transition," PC Tech Journal 4:4, p. 56. It was assembled into
  29. ;    CPUID.OBJ with MASM Version 3.0.
  30. ;
  31. ;    Steve Grant
  32. ;    Long Beach, CA
  33. ;    July 8, 1988
  34. ;
  35. ;-----------------------------------------------------------------------------
  36.  
  37. .287
  38. code    segment    byte public
  39.         assume  cs:code,ds:code
  40.     public    cpuid
  41. cpuid    proc    near
  42.     push    bp
  43.     mov    bp,sp
  44.     xor    ax,ax
  45.     push    ax
  46.     mov    cx,0FFFFH
  47.     sti
  48. rep    lods    byte ptr es:[si]
  49.     pop    ax
  50.     jcxz    a1
  51.     or    ah,08H            ; if CPU is Intel
  52. a1:
  53.     push    ax
  54.     push    sp
  55.     pop    ax
  56.     cmp    ax,sp
  57.     pop    ax
  58.     jne    a2
  59.     or    ah,04H            ; if cpu is 8028x
  60. a2:
  61.     push    ax
  62.     mov    cl,21H
  63.     mov    al,0FFH
  64.     shl    al,cl
  65.     pop    ax
  66.     jz    a3
  67.     or    ah,02H            ; if cpu is 8018x or 8028x
  68. a3:
  69.     push    ax
  70.     mov    ch,0
  71.         push    ds
  72.         push    cs
  73.         pop     ds
  74.     cli
  75.         jmp     $+2                     ; empty queue
  76.     mov    byte ptr a4,0
  77.     db    0B1H            ; MOV    CL,...
  78. a4:    db    1            ; ...1
  79.     sti
  80.         pop     ds
  81.     pop    ax
  82.     jcxz    a5
  83.     or    ah,01H            ; if PIQ length=6 (80x86)
  84. a5:
  85.     cli
  86.     fnstenv    ndp_env
  87.     sti
  88.     fninit
  89.     fnstcw    ndp_cw
  90.     cmp    byte ptr ndp_cw+1,03h
  91.     mov    al,0
  92.     jne    a6
  93.     and    byte ptr ndp_cw,7FH
  94.     fldcw    ndp_cw
  95.     fdisi
  96.     fstcw    ndp_cw
  97.     fldenv    ndp_env
  98.     test    byte ptr ndp_cw,80H
  99.     mov    al,1
  100.     jnz    a6
  101.     mov    al,2
  102. a6:
  103.     pop    bp
  104.     ret
  105. ndp_env    label    word
  106.     dw    7 dup (0)
  107. ndp_cw    label    word
  108.     dw    0
  109. cpuid    endp
  110. code    ends
  111.     end
  112.